#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QPaintEvent>
#include <QMainWindow>
#include <QMainWindow>
#include <QMenu>
#include <QMenuBar>
#include <QMessageBox>
#include <QMouseEvent>
#include <QGroupBox>
#include <QtCharts/QPieSeries>
#include "guideform.h"
#include "dataanaysisform.h"
#include "recordform.h"
#include "predictlineform.h"
#include "console.h"
#include "configform.h"
#include "workplatform.h"
#include "dataanaysisform.h"
#include "recordform.h"
#include "HistoryForm.h"
#include "HistoryForm_1.h"
#include "HistoryForm_2.h"
#include "RadarForm.h"
#include "./utils/DemoduleUtil.h"
#include "./utils/MutiSerialControl.h"
#include "./utils/MutiSignalDecode.h"
#include "demoudleform.h"

typedef QPair<QPointF, QString> Data;
typedef QList<Data> DataList;
typedef QList<DataList> DataTable;

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

QT_CHARTS_USE_NAMESPACE

enum ComPortType{LOW=0,HIGH};
extern MutiSerialControl *mutiSerialControl;
extern MutiSignalDecode *mutiSignalDecode;
extern ConfigForm *cf;

extern HistoryForm_1 *hf_1;
extern HistoryForm_2 *hf_2;
extern DemoudleForm *df;
extern HistoryForm *hf ;
extern RecordForm *rf;
extern PredictLineForm *pl;
extern RadarForm *radarForm;


class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void updateUI(int theme);
    void closeEvent(QCloseEvent *e);
    double* tempArray = NULL;
    void setWinTitle(QString title);
    void setComSerial();
    //void ConsoleData(QString data);
private slots:
    void acceptMutiSerialMessage(int hzType);
    void acceptMessageFromNetwork(QString datas);
    void showMessage();
    void iconActivated(QSystemTrayIcon::ActivationReason reason);
private:
    Ui::MainWindow *ui;
    QLabel *statusLow;
    QLabel *statusSend;
    QLabel *statusTcpIp;
    Console *console;
    void handleError(QSerialPort::SerialPortError error);
    void handleError1(QSerialPort::SerialPortError error);
    void closeSerialPort();
    void showStatusMessage(QString comInfo,int hzType);

    void initActionsConnections();     

    void showMessage(QString message);
    void createActions();
    void createTrayIcon();


    QString str_title;
    QSystemTrayIcon *trayIcon;
    QMenu *trayIconMenu;
    QAction *minimizeAction;
    QAction *maximizeAction;
    QAction *restoreAction;
    QAction *quitAction;

    QTimer *timerIcon = new QTimer();
};

#endif // MAINWINDOW_H
